package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.TgEventEnumsService;
import com.yswy.backstage.service.TgEventService;
import com.yswy.domain.entity.tf.TgEvent;
import com.yswy.domain.entity.tf.TgEventEnums;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.TgEventAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.TgEventEnumsAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import com.yswy.domain.vo.gld.search.TgEventEnumsSearch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/tgEventEnums")
@Api(tags = "回传事件枚举管理")
public class TgEventEnumsController {

    @Autowired
    private TgEventEnumsService tgEventEnumsService;


    @PostMapping("/pageTgEventEnums")
    @ApiOperation(value = "回传事件枚举列表")
    public Page<TgEventEnums> pageTgEventEnums(@RequestBody  TgEventEnumsSearch req, HttpServletRequest request) {
        return tgEventEnumsService.pageTgEventEnums(req);
    }

    @GetMapping("/listTgEventEnums")
    @ApiOperation(value = "回传事件枚举列表")
    public List<TgEventEnums> listTgEventEnums(@RequestParam(value = "tfPlatform" , required = false) String tfPlatform,
                                   HttpServletRequest request) {
        return tgEventEnumsService.listTgEventEnums(tfPlatform);
    }


    @GetMapping("/isExist")
    @ApiOperation(value = "判断事件枚举是否存在")
    public Boolean isExist(@RequestParam(value = "eventKey") String eventKey,
                        HttpServletRequest request) {
        return tgEventEnumsService.isExist(eventKey);
    }


    @PostMapping("/addTgEventEnums")
    @ApiOperation(value = "添加回传事件枚举")
    public void addTgEventEnums(@RequestBody @Validated(BaseReqVO.CREATE.class) TgEventEnumsAddOrUpdate req, HttpServletRequest request) {
        tgEventEnumsService.addOrUpadteTgEventEnums(req);
    }

    @PostMapping("/upadteTgEventEnums")
    @ApiOperation(value = "修改回传事件枚举")
    public void upadteTgEventEnums(@RequestBody @Validated(BaseReqVO.UPDATE.class) TgEventEnumsAddOrUpdate req, HttpServletRequest request) {
        tgEventEnumsService.addOrUpadteTgEventEnums(req);
    }

    @GetMapping("/delTgEventEnums")
    @ApiOperation(value = "删除回传事件枚举")
    public void delTgEventEnums(@RequestParam(value = "tgEventEnumsId") Long tgEventEnumsId,
                                   HttpServletRequest request) {
        tgEventEnumsService.delTgEventEnums(tgEventEnumsId);
    }


}
